package com.wx.wxsecondskill.service;

import com.wx.wxsecondskill.dao.GoodsDao;
import com.wx.wxsecondskill.po.SecondsKillGoods;
import com.wx.wxsecondskill.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName GoodsService
 * @Author wx
 * @Description 商品业务层
 * @Date 2018-11-15-20:40
 */
@Service
public class GoodsService {
    @Autowired
    private GoodsDao goodsDao;
    
    /**
     * @methodName: listGoodsVo
     * @author: wx
     * @description: 查询商品列表
     * @param
     * @date: 2018/11/15
     * @return: java.util.List<com.wx.wxsecondskill.vo.GoodsVo>
     */
    public List<GoodsVo> listGoodsVo(){
        return goodsDao.listGoodsVo();
    }
    
    /**
     * @methodName: getGoodsVoByGoodsId
     * @author: wx
     * @description: 查询商品信息
     * @param goodsId
     * @date: 2018/11/15
     * @return: com.wx.wxsecondskill.vo.GoodsVo
     */
    public GoodsVo getGoodsVoByGoodsId(Integer goodsId) {
        return goodsDao.getGoodsVoByGoodsId(goodsId);
    }
    
    /**
     * @methodName: reduceStock
     * @author: wx
     * @description: 减商品库存
     * @param goods
     * @date: 2018/11/15
     * @return: void
     */
    public void reduceStock(GoodsVo goods) {
        SecondsKillGoods secondsKillGoods = new SecondsKillGoods();
        secondsKillGoods.setGoodsId(goods.getId());
        goodsDao.reduceStock(secondsKillGoods);
    }
}
